package com.gin.kotlin.no_gay_alliance.activity

import android.content.Context
import android.content.Intent
import com.gin.kotlin.no_gay_alliance.base.AbstractBindingActivity
import com.gin.kotlin.no_gay_alliance.databinding.ActivitySourceCodeBinding

class SourceCodeActivity : AbstractBindingActivity<ActivitySourceCodeBinding>() {
    private var code: String? = null

    override fun onCreate() {
        b?.tvSourceCode?.text = code
    }

    override fun onResume() {
        super.onResume()
        setToolbarTitle("源码")
    }
    override fun handleIntent(intent: Intent) {
        this.code = intent.getStringExtra(KEY_ARGUMENT)?.replace("<br/*>".toRegex(),"\n")
    }

    companion object {
        private const val KEY_ARGUMENT = "code"

        @JvmStatic
        fun start(context: Context, sourceCode: String) = context.startActivity(Intent(context, SourceCodeActivity::class.java).putExtra(KEY_ARGUMENT, sourceCode))
    }
}